<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>简答题列表</title>
    <script src="../static/js/jquery.min.js"></script>
</head>
<body>
<table border="1px" class="layui-table">
    <tr>
        <th>编号</th>
        <th>试题内容</th>
        <th>答案</th>
        <th>操作</th>
    </tr>
    <tbody id="choiceData">
    </tbody>
</table><br>
<script>
    $.post("/test/DesignList",{"page":1,"limit":10},function (res) {
        console.log(res);
        var DesList = res.DesList;
        for (var i=0;i<DesList.length;i++){
            var DesQst = DesList[i];
            var trTag = document.createElement("tr");
            var td1 = document.createElement("td");
            td1.innerHTML = DesQst.designQuestion;
            var td2 = document.createElement("td");
            var text1 = document.createElement("textarea");
            text1.innerHTML = DesQst.designInfo;
            td2.appendChild(text1);
            var td3 = document.createElement("td");
            var text2 = document.createElement("textarea");
            text2.innerHTML = DesQst.designAnsw;
            td3.appendChild(text2);
            var td4 = document.createElement("td");
            var btn1 = document.createElement("button");
            btn1.innerText = "修改";
            btn1.onclick = function (){
                window.location.reload(true);
            }
            var btn2 = document.createElement("button");
            btn2.innerText = "删除";
            btn2.id = DesQst.designQuestion;
            btn2.onclick = function(){
                var designQuestion = this.id;
                $.post("/test/deleteDesTest",{"designQuestion":designQuestion},function (res) {
                    window.location.reload(true);
                })
            }
            td4.appendChild(btn1);
            td4.appendChild(btn2);

            trTag.appendChild(td1);
            trTag.appendChild(td2);
            trTag.appendChild(td3);
            trTag.appendChild(td4);

            document.getElementById("choiceData").appendChild(trTag);
        }
    },"json")
</script>
</body>
</html>